import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:im_app/demo/page/CameraSamplePage.dart';
import 'package:im_app/demo/page/EasyRefreshCubit.dart';
import 'package:im_app/demo/page/EasyRefreshPage.dart';
import 'package:im_app/demo/page/ListViewPage.dart';
import 'package:im_app/demo/page/LoadMoreCubit.dart';
import 'package:im_app/demo/page/LoadMoreCubitPage.dart';
import 'package:im_app/demo/page/LoadMorePage.dart';
import 'package:im_app/demo/page/LoopBackSampleWithGetStats.dart';
import 'package:im_app/demo/page/OverlayDemo.dart';
import 'package:im_app/demo/page/PullRefreshCubit.dart';
import 'package:im_app/demo/page/PullRefreshPage.dart';
import 'package:im_app/demo/page/SupListDemo2.dart';
import 'package:im_app/demo/page/footer_underscroll.dart';

import 'page/SupListDemo.dart';

void main() {
  runApp(MainDemoApp());
}

/// Example for EmojiPickerFlutter
class MainDemoApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: '测试',
      theme: ThemeData(
        visualDensity: VisualDensity.adaptivePlatformDensity,
        appBarTheme: const AppBarTheme(scrolledUnderElevation: 0),
      ),
      initialRoute: '/IndexPage',
      routes: {
        '/IndexPage': (BuildContext context) => const IndexPage(),
        '/SupListPage': (BuildContext context) => SupListPage(),
        '/SupListPage2': (BuildContext context) => SupListPage2(),
        '/WebRtcDemo': (BuildContext context) => LoopBackSampleWithGetStats(),
        '/CameraSample': (BuildContext context) => CameraSamplePage(),
        '/PullRefresh': (BuildContext context) => BlocProvider(create: (context)=> PullRefreshCubit(), child: PullRefreshPage(),),
        '/FooterUnderScroll': (BuildContext context) => FooterUnderScroll(),
        '/LoadMore': (BuildContext context) => LoadMorePage(title: 'load more demo'),
        '/LoadMoreCubit': (BuildContext context) => BlocProvider(create: (context)=> LoadMoreCubit(), child: LoadMoreCubitPage(title: 'load more cubit demo'),),
        '/EasyRefresh': (BuildContext context) => BlocProvider(create: (context)=> EasyRefreshCubit(context), child: EasyRefreshPage(),),
        '/OverlayDemo': (BuildContext context) => OverlayDemo(),
        '/ListViewDemo': (BuildContext context) => ListViewPage(),
      },
    );
  }
}

class IndexPage extends StatelessWidget {
  const IndexPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: ListView(
      children: [
        _buildPageLink(context, "SupListDemo", "/SupListPage"),
        _buildPageLink(context, "SupListDemo2", "/SupListPage2"),
        _buildPageLink(context, "WebRtcDemo", "/WebRtcDemo"),
        _buildPageLink(context, "CameraSample", "/CameraSample"),
        _buildPageLink(context, "PullRefresh", "/PullRefresh"),
        _buildPageLink(context, "FooterUnderScroll", "/FooterUnderScroll"),
        _buildPageLink(context, "LoadMore", "/LoadMore"),
        _buildPageLink(context, "LoadMoreCubit", "/LoadMoreCubit"),
        _buildPageLink(context, "EasyRefresh", "/EasyRefresh"),
        _buildPageLink(context, "OverlayDemo", "/OverlayDemo"),
        _buildPageLink(context, "ListViewDemo", "/ListViewDemo"),
      ],
    ));
  }

  Widget _buildPageLink(BuildContext context, String title, String page) {
    return GestureDetector(
      onTap: () {
        Navigator.of(context).pushNamed(page);
      },
      child: ListTile(title: Text(title)),
    );
  }
}

AppBar buildAppbar() {
  return AppBar();
}
